home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Programmation / Alpha ƒ / Tcl / SystemCode / applescript.tcl < prev    next >
Text File  |  1995-06-02  |  3KB  |  78 lines

  1. #############################################################################
  2. # AppleScript.tcl
  3. #  John Sarapata
  4. #  sarapata_john@jpmorgan.com
  5. #
  6. # Installing:
  7. #    Put AppleScript.tcl in your Usercode folder
  8. #   Put the following line in userstartup.tcl:
  9. #     source $HOME:Tcl:Usercode:AppleScript.tcl
  10. #
  11. # Description:
  12. #    This file implements an AppleScript mode, for people who wish Script
  13. #    Editor had complex functions like search and replace. Currently, it
  14. #    only supports color editing and function finding, but I may extend it.
  15. #
  16. #    I have not found a way to distinguish function definitions from
  17. #    on error constructs, so I assume that any "on name" statements at
  18. #    the beginning of the line are definitions. Script Editor saves files
  19. #    in this format, so you will only need to be careful when creating
  20. #    functions in Alpha.
  21. #############################################################################
  22.  
  23. #===============================================================================
  24. #    Set up the mode variables
  25. newModeVar    Scrp     elecRBrace            {0}    1
  26. newModeVar    Scrp     electricSemi        {0}    1
  27. newModeVar    Scrp    elecLBrace            {0} 1
  28. newModeVar    Scrp    electricTab            {0} 1
  29. newModeVar    Scrp    wordWrap            {0} 1
  30. newModeVar    Scrp    autoMark            {0}    1
  31. newModeVar    Scrp    prefixString        {--} 0
  32. newModeVar    Scrp    leftFillColumn         {3} 0
  33. newModeVar    Scrp    funcExpr            {^(ON)[ \t]+([a-zA-Z0-9_]+)} 0
  34. newModeVar    Scrp    wordBreak             {[a-zA-Z0-9_]+} 0
  35. newModeVar    Scrp    wordBreakPreface     {[^a-zA-Z0-9_]} 0
  36.  
  37. proc dummyScrp {} {}
  38.  
  39. #===============================================================================
  40. #    Set up comments and keywords
  41. set scriptKeyWords {
  42.     on end error global local return it me pi result space tab
  43.     close copy count data size delete duplicate exists get launch
  44.     make move open print quit run save in of is after before
  45.     div mod and not or start starts begin begins end ends contains
  46.     does equal equals greater less than as reference
  47.     set try
  48.     tell if repeat else then times while until with by
  49.     considering ignoring timeout transaction script property prop
  50.     first second third fourth fifth sixth seventh eighth ninth tenth
  51.     last front back middle every some from to through thru
  52. }
  53.  
  54. regModeKeywords -e {--} -b {\(*} {*\)} -c red -k blue Scrp $scriptKeyWords
  55.  
  56. unset scriptKeyWords
  57.  
  58. #===============================================================================
  59. #    File Marking
  60. proc ScrpMarkFile {} {
  61.     global ScrpmodeVars
  62.     set pos 0
  63.     while {![catch {search -f 1 -r 1 -m 0 -i 1 $ScrpmodeVars(funcExpr) $pos} res]} {
  64.         set start [lindex $res 0]
  65.         set end [lindex $res 1]
  66.         set text [lindex [getText $start $end] 1]
  67.         set pos $end
  68.         set inds($text) "$start $end"
  69.     }
  70.     
  71.     if {[info exists inds]} {
  72.         foreach f [lsort [array names inds]] {
  73.             setNamedMark $f [lineStart [lineStart [lindex $inds($f) 0]] - 1] [lindex $inds($f) 0] [lindex $inds($f) 1]
  74.         }
  75.     }
  76. }
  77.  
  78.